</head>
<body>
<div class="f-sep10"></div>
<div class="f-sep10"></div>
<div class="m-hd m-tabs">
<h2 class="u-tt">APP管理</h2>
	<div class="more"><a href="javascript:;" onClick="window.location.reload();"><span class="icon">&#xf021;</span> 刷新</a></div>
    <ul>
        <li><a class="z-crt" href="javascript:;"><span class="icon">&#xf101;</span> APP列表</a></li>
    </ul>
</div>
<div class="m-list3 m-list3-x m-applist">
    <ul class="f-cb">
		<!--foreach:{$app_list $key $vo}-->
		<?php if(!$vo['APP_SYSTEM']){
		if(!$vo['APP_INSTALL']){
		$class='s-warning';
		}else if(!$vo['APP_STATE']){
		$class='s-error';
		}else{
		$class='s-success';
		}
		 ?>
        <li class="{$class}">
            <div class="u-img"><span class="icon">
			<?php if($vo['APP_ICO']){ ?>
			{$vo.APP_ICO}
			<?php }else{ ?>
			&#xf0c1;
			<?php } ?>
			</span></div>
            <div class="txt">
                <h3><a href="javascript:;">{$vo.APP_NAME}</a> - {$vo.APP_VER} - {$vo.APP_AUTHOR}</h3>
                <p>{$vo.APP_DESCRIPTION}</p>
                <p>
				<?php if(!$vo['APP_SYSTEM']){ ?>
				
				<?php if(!$vo['APP_INSTALL']){ ?>
				<button type="button" class="u-btn u-btn-c4 u-btn-sm" onClick="install('{$key}')">安装</button>
				<?php }else{ ?>
				<?php if(!$vo['APP_STATE']){ ?>
				<button type="button" class="u-btn u-btn-c4 u-btn-sm" onClick="status_app('{$key}')">启用</button> 
				<?php }else{ ?>
				<button type="button" class="u-btn u-btn-c4 u-btn-sm" onClick="status_app('{$key}')">禁用</button> 
				<?php } ?>
				<button type="button" class="u-btn u-btn-c4 u-btn-sm" onClick="uninstall('{$key}')">卸载</button>
				<button type="button" class="u-btn u-btn-c4 u-btn-sm" onClick="database('{$key}')">数据</button>
				<?php } ?>
				
				<?php }else{ ?>
				系统组件无法操作
				<?php } ?>
				
				</p>
            </div>
        </li>
        <?php }	 ?>
		<!--{/foreach}-->
        
    </ul>
</div>
</body>
<script>
var install = new function(){}; 
var uninstall = new function(){}; 
var export_app = new function(){}; 
var status_app = new function(){}; 
var database = new function(){}; 
var restore_app = new function(){}; 
var package_app = new function(){}; 
Do.ready('base','dialog', function() {
	window.install = function install(name) {
		ajaxpost({
		name:'确定要安装本APP吗？',
		url:'{$url(admin_list/install)}',
		data:{name:name},
		tip:true,
		success:function(){
			setTimeout('window.location.reload(); ',1000);
			}
		});
	}
	
	window.uninstall = function uninstall(name) {
		ajaxpost({
		name:'确定要卸载本APP吗？',
		url:'{$url(admin_list/uninstall)}',
		data:{name:name},
		tip:true,
		success:function(){
			setTimeout('window.location.reload(); ',1000);
			}
		});
	}
	
	window.database = function database(name) {
		art.dialog({
			title: '消息',
			content: '请选择您要进行的数据操作！',
			icon: 'question',
			button: [
				{
					name: '备份数据',
					callback: function () {
						export_app(name);
					},
					focus: true
				},
				{
					name: '恢复收据',
					callback: function () {
						restore_app(name);
					}
				},
				{
					name: '打包安装数据',
					callback: function () {
						package_app(name);
					}
				}
			]
		});
	}
	
	window.export_app = function export_app(name) {
		ajaxpost({
		name:'确定要备份这个APP的数据吗？',
		url:'{$url(admin_list/export)}',
		data:{name:name},
		tip:true,
		success:function(){
			setTimeout('window.location.reload(); ',1000);
			}
		});
	}
	
	window.restore_app = function restore_app(name) {
		ajaxpost({
		name:'确定要恢复本APP数据吗？',
		url:'{$url(admin_list/restore)}',
		data:{name:name},
		tip:true,
		success:function(){
			setTimeout('window.location.reload(); ',1000);
			}
		});
	}
	
	window.package_app = function package_app(name) {
		ajaxpost({
		name:'确定要将本APP数据打包成安装数据吗？',
		url:'{$url(admin_list/package)}',
		data:{name:name},
		tip:true,
		success:function(){
			setTimeout('window.location.reload(); ',1000);
			}
		});
	}
	
	window.status_app = function status_app(name) {
		ajaxpost({
		name:'确定要切换本APP状态吗？',
		url:'{$url(admin_list/status)}',
		data:{name:name},
		tip:true,
		success:function(){
			setTimeout('window.location.reload(); ',1000);
			}
		});
	}
});
</script>